package top.hmtools.mapper.plus.mysql.delete;

import org.apache.ibatis.mapping.MappedStatement;

import tk.mybatis.mapper.mapperhelper.MapperHelper;
import top.hmtools.mapper.plus.mysql.BaseMysql;

public class DeleteMapperPlusProvider extends BaseMysql{
	
	public DeleteMapperPlusProvider(Class<?> mapperClass, MapperHelper mapperHelper) {
		super(mapperClass, mapperHelper);
	}

	/**
	 * 指定主键名称（Java类字段名字符串），主键集合，删除指定记录集合
	 * <br><b>注意入参异常造成误删除全部数据的危害</b>
	 * @param ms
	 * @return
	 */
	public String delSomeByPk(MappedStatement ms){
		final Class<?> entityClass = getEntityClass(ms);
		return this.mergeToSQLstr(entityClass, "delete/delSomeByPk");
	}
	
	/**
	 * 根据条件删除
	 * <br><b>注意入参异常造成误删除全部数据的危害</b>
	 * @param ms
	 * @return
	 */
	public String delSomeByCondition(MappedStatement ms) {
		final Class<?> entityClass = getEntityClass(ms);
		return this.mergeToSQLstr(entityClass, "delete/delSomeByCondition");
	}
	
	/**
	 * 支持批量的逻辑删除
	 * @param ms
	 * @return
	 */
	public String delSomeByPkLogic(MappedStatement ms){
		final Class<?> entityClass = getEntityClass(ms);
		return this.mergeToSQLstr(entityClass, "update/updateSomeTheColumnByPk");
	}
}
